Skip to content

Conversation

@chengoramazon
Copy link
Contributor

@chengoramazon chengoramazon commented Oct 10, 2024

Problem

  • Static errorName is unnecessary in feature dev error classes. It also causes error code mismatches some of errorName which result in wrong state.

Solution

  • Remove errorName from error classes
  • use class name match to ensure error handled correctly.
  • Add unit tests to cover all the error cases.

License: I confirm that my contribution is made under the terms of the Apache 2.0 license.

@chengoramazon chengoramazon force-pushed the chengora/refactor-errors branch from 0e93a97 to 124dc72 Compare October 12, 2024 02:52
@chengoramazon chengoramazon marked this pull request as ready for review October 12, 2024 03:02
@chengoramazon chengoramazon requested a review from a team as a code owner October 12, 2024 03:02
)
})

it('should handle default errors', async function () {
Copy link
Contributor

@justinmk3 justinmk3 Oct 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each of these tests is near-identical. Part of the job of developing this project is to look for ways to reduce duplicate code and increase maintainability. Hundreds of lines of duplicate code is unacceptable. Please keep this in mind for future contributions.

Copy link
Contributor

@justinmk3 justinmk3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

latest push has lots of duplicate code

@chengoramazon chengoramazon force-pushed the chengora/refactor-errors branch from 124dc72 to 483e717 Compare October 15, 2024 16:47
}

runs.forEach((run) => {
it(`should handle ${run.name}`, async function () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reference this is one way of de-duplicating tests, but it would also be fine to have a bunch of manally-declared it() blocks which call a common function.

@justinmk3 justinmk3 merged commit 570eaf3 into aws:master Oct 15, 2024
21 of 24 checks passed
@justinmk3
Copy link
Contributor

Thank you for this clean up!

@chengoramazon chengoramazon deleted the chengora/refactor-errors branch October 15, 2024 20:11
tverney pushed a commit to tverney/aws-toolkit-vscode that referenced this pull request Oct 21, 2024
## Problem
- Static `errorName` is unnecessary in feature dev error classes. It
also causes error code mismatches some of errorName which result in
wrong state.

## Solution
- Remove `errorName` from error classes
- use class name match to ensure error handled correctly.
- Add unit tests to cover all the error cases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants